﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Pub;

namespace JCNT.DAL
{
    public class C_CMS
    {
        CADO ado1 = new CADO();
        string s_sql = "";

        public string note_Add(string s_tit, string s_lab, string s_con, string s_oth, string s_dat)
        {
            //s_tit = Pub.AddY_H_(s_tit);
            //s_con = Pub.AddY_H_(s_con);
            //s_lab = Pub.AddY_H_(s_lab);
            //s_oth = Pub.AddY_H_(s_oth);
            s_tit = s_tit.Replace("'", "''");
            s_con = s_con.Replace("'", "''");
            s_lab = s_lab.Replace("'", "''");
            s_oth = s_oth.Replace("'", "''");

            s_sql = "insert into wp_note("
                + "tit,"
                + "lab,"
                + "con,"
                + "oth,"
                + "setDat"
                + ") "
                + " values("
                + "'" + s_tit + "',"
                + "'" + s_lab + "',"
                + "'" + s_con + "',"
                + "'" + s_oth + "',"
                + "'" + s_dat + "'"
                + ")";
            ado1.cmd1(s_sql);

            s_sql = "select top 1 id,setdat from wp_note order by setdat desc";
            string s_id = ado1.sel1(s_sql).Tables[0].Rows[0]["id"].ToString();
            return s_id;    // 返回编号
        }

        public void note_Edt(string s_id, string s_tit, string s_con, string s_lab, string s_oth, string s_dat)
        {
            s_tit = s_tit.Replace("'", "''");
            s_con = s_con.Replace("'", "''");
            s_lab = s_lab.Replace("'", "''");
            s_oth = s_oth.Replace("'", "''");

            s_sql = "update wp_note set "
                + "tit='" + s_tit + "',"
                + "con='" + s_con + "',"
                + "lab='" + s_lab + "',"
                + "oth='" + s_oth + "',"
                + "setDat='" + s_dat + "' "
                + "where id = " + s_id;
            ado1.cmd1(s_sql);
        }

        public void note_Del(string s_ID)
        {
            string s_sql = "delete from wp_note where id=" + s_ID;
            ado1.cmd1(s_sql);
        }
    }
}
